﻿namespace Pp.Domain.Mappings
{
    using Model;

    public sealed class UserMap : EntityMap<User>
    {
        public UserMap()
        {
            Table("Users");
            Map(d => d.Username).Unique().Not.Nullable().Length(64);
            Map(d => d.Password).Not.Nullable().Length(64);
            Map(d => d.OldPassword).Length(64);
            Map(d => d.MailAdress).Unique().Not.Nullable();
            Map(d => d.IsActive);
            Map(d => d.FirstName);
            Map(d => d.LastName);
            Map(d => d.CvInfo).Length(MAX_LENGTH);
            Map(d => d.EducationalInfo).Length(MAX_LENGTH);
            Map(d => d.WorkInfo).Length(MAX_LENGTH);
            Map(d => d.BirthDay);
            Map(s => s.IsMan);
            Map(d => d.MailAdressVisible);
            HasMany(d => d.Projects).KeyColumn("UserId").LazyLoad();
            HasMany(d => d.MyLikes).KeyColumn("ProcessorId").LazyLoad();
            HasMany(d => d.TheyLikes).KeyColumn("UserId").LazyLoad();
            HasMany(d => d.Comments).KeyColumn("UserId").LazyLoad();
            HasMany(d => d.AngelRequests).KeyColumn("UserId").LazyLoad();
            HasMany(d => d.MyFollows).KeyColumn("FollowerId").LazyLoad();
            HasMany(d => d.TheyFollows).KeyColumn("UserId").LazyLoad();
            Map(d => d.City);
        }
    }
}
